class Solution(object):
    def addDigits(self, num):
        """
        :type num: int
        :rtype: int
        """
        s = str(num)
        while len(s) > 1:
            num = 0
            for i in range(len(s)):
                num += int(s[i])
            s = str(num)
        return int(s)
